package com.activemq;

import com.activemq.producer.IMessageProducerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Queue;
import javax.jms.Topic;

@RestController
@SpringBootApplication
public class ActivemqApplication {

	@Autowired
	private IMessageProducerService messageProducerQueueService;

	@Autowired
	private IMessageProducerService messageProducerTopicService;


	@Autowired
	private Topic topic;

	@Autowired
	private Topic topic2;

	@Autowired
	private Queue queue;

	public static void main(String[] args) {
		SpringApplication.run(ActivemqApplication.class, args);
	}

	@RequestMapping("sendQueue")
	public void sendQueue(String msg){
		messageProducerQueueService.sendMessageQueue(msg,queue);
	}

	@RequestMapping("sendTopic")
	public void sendTopic(String msg){
		messageProducerTopicService.sendMessage(msg,topic);
	}

	@RequestMapping("sendTopic2")
	public void sendTopic2(String msg){
		messageProducerTopicService.sendMessage(msg,topic2);
	}
}
